//
//  InSaleGoodsTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/5.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "InSaleGoodsTableViewCell.h"

@interface InSaleGoodsTableViewCell ()
@property (nonatomic,strong)GLGWImageView * goodsImageView;
@property (nonatomic,strong)GLGWLabel * stellNameLabel;
@property (nonatomic,strong)GLGWLabel * specLabel;
@property (nonatomic,strong)GLGWLabel * warehoseLabel;
@property (nonatomic,strong)GLGWLabel * piceLabel;

@property (nonatomic,strong)GLGWLabel * inventoryLabel;


@end

@implementation InSaleGoodsTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        GLGWView * bankgroundView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        [bankgroundView setViewShadowWidth:3.0 theCornerRadius:3.0];
        [bankgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
        }];
        //
        self.goodsImageView = [[GLGWImageView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(13), kHeightProportion_In_iPhoneTriploid(15), kWidthProportion_In_iPhoneTriploid(90), kHeightProportion_In_iPhoneTriploid(90)) inSuperView:bankgroundView];
        self.goodsImageView.backgroundColor = kRandomColor;
        //
        self.stellNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:bankgroundView];
//        self.stellNameLabel.backgroundColor = kRandomColor;
//        self.stellNameLabel.text = @"三级螺纹钢 HRB400E 河钢";
        [self.stellNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.goodsImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(20));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
        }];
        //
        self.specLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:bankgroundView];
//        self.specLabel.backgroundColor = kRandomColor;
//        self.specLabel.text = @"φ6*12";
        [self.specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stellNameLabel);
            make.top.equalTo(self.stellNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
        }];
        //
        self.warehoseLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
//        self.warehoseLabel.backgroundColor = kRandomColor;
//        self.warehoseLabel.text = @"北京京南国储库";
        [self.warehoseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.specLabel);
            make.top.equalTo(self.specLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        //
        self.piceLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:bankgroundView];
//        self.piceLabel.backgroundColor = kRandomColor;
//        self.piceLabel.text = @"¥3845/吨";
        self.piceLabel.textAlignment = NSTextAlignmentRight;
        [self.piceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.warehoseLabel.mas_right).offset(kWidthProportion_In_iPhoneTriploid(10));
            make.bottom.equalTo(self.warehoseLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(1));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
        }];
        // 设置优先级
        [self.warehoseLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
        [self.piceLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh) forAxis:(UILayoutConstraintAxisHorizontal)];
        /*-------z自由经理人--------*/
        if (self.accountType == AccountType_FreeManagers) {
            [self.stellNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.goodsImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
                make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(12));
                make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            }];
            //
            [self.piceLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.warehoseLabel);
                make.top.equalTo(self.warehoseLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
                make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
            }];
            //
            self.inventoryLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
            self.inventoryLabel.textAlignment = NSTextAlignmentRight;
            self.inventoryLabel.text = @"库存36件";
            self.inventoryLabel.backgroundColor = kRandomColor;
            [self.inventoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.specLabel.mas_right).offset(kWidthProportion_In_iPhoneTriploid(10));
                make.top.equalTo(self.stellNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(8));
                make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            }];
            [self.specLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
            [self.inventoryLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh) forAxis:(UILayoutConstraintAxisHorizontal)];
            //
            GLGWButton * inPutStoreBut = [[GLGWButton alloc] initWithTitle:@"立即同步" titleLableFont:SYSTEMFONT(12) titleLableColor:[UIColor whiteColor] theCornerRadius:3.0 backgroundColr:kColor_Rule_Yellow inSuperView:bankgroundView];
            [inPutStoreBut mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.equalTo(bankgroundView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
                make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
                make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(55)));
                make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(25)));
            }];
        }
        
    }
    return self;
}

-(void)setStoreInfosModel:(StroeAllGoodsModel_Infos *)storeInfosModel{
    _storeInfosModel = storeInfosModel;
    self.stellNameLabel.text = [NSString stringWithFormat:@"%@  %@  %@",koString(_storeInfosModel.productsSeller.productName),koString(_storeInfosModel.productsSeller.productMaterial),koString(_storeInfosModel.productsSeller.factoryName)];
    self.specLabel.text = _storeInfosModel.productsSeller.specifications;
    //
    self.warehoseLabel.text = _storeInfosModel.productsSeller.storehouseName;
    //
    self.piceLabel.text = [NSString stringWithFormat:@"¥%.2f/吨",_storeInfosModel.price];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
